home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-01-31 | 4.1 KB | 108 lines | [TEXT/R*ch] |
- // ===========================================================================
- // File: CInternalCmdKeyAttachment.cp
- // Version: 1.0.1 - Jan 31, 1997
- // Author: Mike Shields (mshields@inconnect.com)
- //
- // Copyright ©1996 Mike Shields. All rights reserved.
- // I hereby grant users of CInternalCmdKeyAttachment permission to use it (or any modified
- // version of it) in applications (or any other type of Macintosh software
- // like extensions -- freeware, shareware, commercial, or other) for free,
- // subject to the terms that:
- //
- // (1) This agreement is non-exclusive.
- //
- // (2) I, Mike Shields, retain the copyright to the original source code.
- //
- // These two items are the only required conditions for use. However, I do have
- // an additional request. Note, however, that this is only a request, and
- // that it is not a required condition for use of this code.
- //
- // (1) That I be given credit for CInternalCmdKeyAttachment code in the copyrights or
- // acknowledgements section of your manual or other appropriate documentation.
- //
- //
- // I would like to repeat that this last item is only a request. You are prefectly
- // free to choose not to do any or all of them.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // ===========================================================================
- // CInternalCmdKeyAttachment.h <- double-click + Command-D to see class declaration
- //
- // Class which handles drawing and responding to command keys when it is attached
- // to a button
-
- #include "CInternalCmdKeyAttachment.h"
- #include <LStream.h>
-
- //----------------------------------------------------------------------------------------
- // CInternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- CInternalCmdKeyAttachment* CInternalCmdKeyAttachment::CreateFromStream(LStream *inStream)
- {
- return new CInternalCmdKeyAttachment(inStream);
- }
-
- //----------------------------------------------------------------------------------------
- // CExternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- CInternalCmdKeyAttachment::CInternalCmdKeyAttachment()
- : mShowingCommandKey(false)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CInternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- CInternalCmdKeyAttachment::CInternalCmdKeyAttachment(LStream *inStream)
- : CCmdKeyAttachment(inStream), mShowingCommandKey(false)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CInternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- CInternalCmdKeyAttachment::~CInternalCmdKeyAttachment()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CInternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- void CInternalCmdKeyAttachment::EnableCommandKey(Boolean inCmdDown)
- {
- if ( inCmdDown == true && mShowingCommandKey == false )
- DrawCommandKey(true);
- else if ( inCmdDown == false && mShowingCommandKey == true )
- DrawCommandKey(false);
- }
-
- //----------------------------------------------------------------------------------------
- // CInternalCmdKeyAttachment::DrawCommandKey
- //----------------------------------------------------------------------------------------
- void CInternalCmdKeyAttachment::DrawCommandKey(Boolean inVisible)
- {
- LStr255 controlTitle;
-
- mMyControl->GetDescriptor(controlTitle);
-
- if ( inVisible )
- {
- char temp = mCommandKey;
-
- ::UpperText(&temp, 1);
- controlTitle += char_Space;
- controlTitle += char_Propeller;
- controlTitle += temp;
- }
- else
- controlTitle.Remove(controlTitle.Length() - 2, 3);
-
- mShowingCommandKey = inVisible;
-
- mMyControl->SetDescriptor(controlTitle);
- }
-
-
-